package org.csu.hotelsys.service;

import org.csu.hotelsys.domain.Journal;
import org.csu.hotelsys.persistence.JournalMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JournalService {
    @Autowired
    public JournalMapper journalMapper;

    public List<Journal> getJournalList() {
        return journalMapper.getJournalList();
    }

    //根据操作编号获取日志
    public Journal getJournalByID(String operate_id) {
        return journalMapper.getJournalByID(operate_id);
    }

    //根据操作时间获取日志
    public List<Journal> getJournalListByTime(String operate_time) {
        return journalMapper.getJournalListByTime(operate_time);
    }

    //根据操作者获取日志
    public List<Journal> getJournalListByOperater(String operater) {
        return journalMapper.getJournalListByOperater(operater);
    }

    //根据操作类型获取日志
    public List<Journal> getJournalListByType(String operate_type) {
        return journalMapper.getJournalListByType(operate_type);
    }

    //新增日志
    public void addJournal(Journal journal) {
        String id = journal.getJournal_id();
        String time = journal.getOperate_time();
        String operater = journal.getOperater();
        String type = journal.getOperate_type();
        journal.setJournal_id(id);
        journal.setOperate_time(time);
        journal.setOperater(operater);
        journal.setOperate_type(type);
        journalMapper.addJournal(journal);

    }

    //修改日志信息
    public void updateOperateInfo(String info) {
        journalMapper.updateOperateInfo(info);
    }

    //根据操作编号删除日志
    public void deleteJournalByID(String operate_id) {
        journalMapper.deleteJournalByID(operate_id);
    }
}
